/*
 * UI功能模块
 *
 */

define([
    'jquery',
    'libs/layer/layer',
    'common/template'
], function($,layer,template) {
    return {
        /*
         * 警告框
         *
         * status   状态 success|info|error|waring
         * msg      信息
         */
    	alert: function(title, msg, _callback){
    		layer.alert(msg,{
    			title:title,
    			skin: 'layui-layer-molv',
    			closeBtn: 0,
    			anim: 0,
    			success: function (layero) {
    				//按钮居中
    				var btn = layero.find('.layui-layer-btn');
    				btn.css('text-align', 'center');
    				//内容居中
    				var content = layero.find('.layui-layer-content');
    				content.css("text-align","center");
    			}
    		},
    		function(c_index){
    			layer.close(c_index);
    			if (_callback){
    				_callback();
    			}
    		});
    	},
        /*
         * 确认框
         *
         * title 标题
         * content 内容
         * confirmCallback　确认后回调方法
         * cancelCallback 取消后回调方法
         */
	    confirm: function(title, content, arg, confirmCallback, cancelCallback) {
	    	layer.confirm(
	    		content, 
	    		{
	    			title:title,
	    			skin: 'layui-layer-molv',
	    			success: function (layero) {
	    				//按钮居中
	    				var btn = layero.find('.layui-layer-btn');
	    				btn.css('text-align', 'center');
	    				//内容居中
	    				var content = layero.find('.layui-layer-content');
	    				content.css("text-align","center");
	    			}
	    		}, 
	    		function(index){
	    			layer.close(index);
	    			if (confirmCallback)
	    				confirmCallback(arg);
	    		}, 
	    		function(index){
	    			layer.close(index);
	    			if (cancelCallback)
	    				cancelCallback(arg);
	    		}
	    	);
	    }
    };
});